package net.cyndeline.components.objectProperties

import net.cyndeline.entitySystem.Component
import com.escalatesoft.subcut.inject.BindingModule
import com.escalatesoft.subcut.inject.Injectable
import net.cyndeline.subcut.BindingKeys.DefaultItemName

/**
 * Gives a name to any entity that owns it and exists on the map.
 * The name is not required to be unique, and should not be used as identifier.
 */
trait NameComponent extends Component {
  
  /** Returns the entity's name. */
  def name: String
}

class Name(implicit val bindingModule: BindingModule) extends NameComponent with Injectable {
  var name: String = injectOptional [String](DefaultItemName) getOrElse "<default_name>"
  
  override def copy = {
    val copy = new Name()
    copy.name = name
    copy
  }
}